﻿using UnityEngine;

[RequireComponent(typeof(Collider2D))]
public class GroundInfo : USaBehaviour
{
    [Tooltip("地面类型")]
    public GroundType groundType;

    [Tooltip("是否可以穿过（包括上跳和下跳）")]
    public bool canJumpAcross;

    /// <summary>
    /// 碰撞体
    /// </summary>
    public Collider2D colli => m_Colli ?? (m_Colli = m_Colli.GetComponent<Collider2D>());

    private Collider2D m_Colli;

    /// <summary>
    /// 碰撞体中心
    /// </summary>
    public Vector2 center => (Vector2)transform.position + colli.offset;

    /// <summary>
    /// 摩擦系数
    /// </summary>
    public float coefficient => groundType switch
    {
        GroundType.ground => 1f,
        GroundType.ice => 0.2f,
        _ => 1f
    };
}